package sky.treasure.properties;

import sky.treasure.Cell;
import sky.treasure.Coordinates;
import sky.treasure.results.IResult;

import java.util.HashSet;

/**
 * Created with IntelliJ IDEA.
 * User: Gauss
 * Date: 09.01.14
 * Time: 22:55
 * To change this template use File | Settings | File Templates.
 */
public abstract class AreaProperty implements IProperty {

    protected HashSet<Coordinates> coordinatesSet;

    protected AreaProperty() {
        coordinatesSet = new HashSet<Coordinates>();
    }

    protected AreaProperty(HashSet<Coordinates> coordinates) {
        this.coordinatesSet = coordinates;
    }

    public AreaProperty addCoordinates(Coordinates coordinates) {
        coordinatesSet.add(coordinates);
        return this;
    }

    public void modifyCell(Cell cell) {
        if (coordinatesSet.contains(cell.getCoordinates())) {
            cell.addProperty(this);
        }
    }

    public abstract IResult interactWithCell(Cell cell);
    public abstract IResult analyzeCell(Cell cell);
}
